#pragma once

#include <rocksdb/db.h>
#include <rocksdb/options.h>
#include <rocksdb/write_batch.h>

#include <string>

namespace libraft {
class Raft;
class Meta {
 public:
  Meta(const std::shared_ptr<rocksdb::DB>& meta);
  ~Meta();

  void Open();
  uint64_t GetCurrentTerm();
  void SetCurrentTerm(const uint64_t current_term);

  std::string GetVotedForIp();
  int GetVotedForPort();

  void SetVotedForIp(const std::string& ip);
  void SetVotedForPort(const int port);

  uint64_t GetCommitIndex();
  void SetCommitIndex(const uint64_t commit_index);

  uint64_t GetLastApplied();
  void SetLastApplied(uint64_t last_applied);

 private:
  Meta(const Meta&);
  void operator=(const Meta&);

  const std::shared_ptr<rocksdb::DB> meta_;
};

}  // namespace libraft